###############################################################################
#
# $Id: Makefile,v 1.5 2008-06-13 11:44:39 amaula Exp $
#
# \file Makefile
# \brief Makefile for MaCI Launcher
# \author Antti Maula <antti.maula@tkk.fi>
#
###############################################################################

# GDIR define
GDIR=../..

# MACIPATH define
MACIPATH=$(GDIR)/MaCI

# params
CC=gcc
CXX=g++
EXTRADEFS=-DLINUX_OS
MACIPATH=$(GDIR)/MaCI
UTILSPATH=$(GDIR)/utils
INCLUDES=-I$(UTILSPATH)
CFLAGS=-O0 -g3 -Wall $(INCLUDES) $(CE) \
	$(EXTRADEFS)
CPPFLAGS=-O0 -g3 -Wall $(INCLUDES) -Weffc++ $(EXTRADEFS) `xml2-config --cflags`
DCPPFLAGS=-O0 -g3 -Wall $(INCLUDES) $(EXTRADEFS) `xml2-config --cflags`
LD=g++
LDFLAGS=
LIBS=-lrt -lpthread $(LIBSGIMI) `xml2-config --libs`


# Sources 'base' (required external links)
SRCSC=$(UTILSPATH)/ownutils.c $(UTILSPATH)/owndebug.c
SRCSCPP=main.cpp executor.cpp directory.cpp \
	launcher.cpp configreader.cpp
VPATH=

# Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp)

# Define COMPILE and LINK commands
COMPILEC=$(CC) $(CFLAGS) -c
COMPILECPP=$(CXX) $(CPPFLAGS) -c
COMPILEDCPP=$(CXX) $(DCPPFLAGS) -c
LINK=$(LD) $(LDFLAGS) $(LIBS)

.PHONY: all clean real-clean

all:	Launcher

Launcher: $(OBJSC) $(OBJSCPP)
	@$(LINK) -o $@ $^
	@echo "      [LD] $@"

clean:
	@rm -f *.o *.opp *~
	@echo "      [CLEAN]"

real-clean realclean: clean
	@rm -f $(OBJSC) $(OBJSCPP)
	@echo "      [REAL-CLEAN]"


# Compile rule for all .o (.c) file
%.o:	%.c
	@$(COMPILEC) -o $@ $<
	@echo "      [CC] $<"

# Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
	@$(COMPILECPP) -o $@ $<
	@echo "      [CXX] $<"

# Compile rule for all .dopp (dirty .cpp) files
%.dopp:	%.cpp
	@$(COMPILEDCPP) -o $@ $<
	@echo "      [DIRTY-CXX] $<"

